package com.briup.jz.service.impl;

import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.briup.jz.bean.Category;
import com.briup.jz.bean.CategoryExample;
import com.briup.jz.bean.Comment;
import com.briup.jz.bean.CommentExample;
import com.briup.jz.bean.Order;
import com.briup.jz.bean.OrderExample;
import com.briup.jz.dao.CommentMapper;
import com.briup.jz.service.ICommentService;
import com.briup.jz.utils.CustomerException;

@Service
public class CommentServiceImpl implements ICommentService {
	@Autowired
	private CommentMapper commentMapper;
	
	@Override
	
	public void saveOrUpdate(Comment comment) throws CustomerException {
		if(comment.getId()!=null) {
			commentMapper.updateByPrimaryKey(comment);
		} 
			commentMapper.insert(comment);
		
	}
	
	
	@Override
	public void deleteById(long id) throws CustomerException {
		Comment comment = commentMapper.selectByPrimaryKey(id);
		if(comment == null) {
			throw new CustomerException("要删除的评论信息不存在");
		}
		commentMapper.deleteByPrimaryKey(id);
		
	}



	@Override
	public void check(long id, String status) throws CustomerException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void batchDelete(ArrayList<Long> id) throws CustomerException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void pageQuery(String page, String pageSize, String keywords) throws CustomerException {
		// TODO Auto-generated method stub
		
	}
    @Override
	public List<Comment> query(Long id) {
		CommentExample example = new CommentExample();
		if(id!=null){
			example.createCriteria().andIdEqualTo(id);
		}
		List<Comment> list = commentMapper.selectByExample(example);
		return list;
	}

}
